<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录页面</title>
</head>
<body>

	<center>
		<form action="#" method="post">
			<table>
				<tr>
					<td>用户名:<input type="text" name="name" id="te"><span id="ts"></span></td>
				</tr>
				<tr>
					<td>密码:<input type="password" name="password" id="pas"><span id="tp"></span></td>
				</tr>
				<tr>
					<td><input type="button" value="登录" id="backid"></td>
					<td><input type="button" value="注册" onclick="javascrtpt:window.location.href='zhuce.jsp'"></td>
				</tr>
			</table>
		</form>
	</center>
	<script src="./public/js/jquery-3.1.1.min.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			
			$("#te").focus(function() {

				$("#ts").html("请输入账号!");
			});
			$("#te").blur(function() {
				var name = $("#te").val();
				$.ajax({
					type : 'post',
					url : 'selectname',
					data : {
						'name' : name
					},
					dataType : 'json',
					error : function() {
						alert("error!");
					},

					success : function(result) {
						if (result == 1) {
							
							$("#ts").html("");
							$("#ts").css("color", "red");
						} else if (result == 0) {
							
							$("#ts").html("该用户名不存在");
							$("#ts").css("color", "green");

						}
					}

				});

			});


			 $("#backid").click(function() {

		         window.loction.href="biaoti";

		         });
			$("#pas").blur(function() {
				
				var password = $("#pas").val();
				
				$.ajax({
					type : 'post',
					url : 'selectpass',
					data : {
						
						'password' : password
					},
					dataType : 'json',
					error : function() {
						alert("error!");
					},

					success : function(result) {
						if (result == 1) {
							//alert("用户不可用");
							$("#tp").html("");
							$("#tp").css("color", "green");
							
						} else if (result == 0) {
							//alert("用户可用!");
							$("#tp").html("密码错误");
							
							$("#tp").css("color", "red");

						}
					}

				});
			});
		 });
		});
	</script>
</body>
</html>